package com.neuq.animaladoption.validation;

import com.neuq.animaladoption.anno.AnimalType;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class AnimalTypeValidation implements ConstraintValidator<AnimalType,String> {
    /**
     *
     * @param s 将来要校验的数据
     * @param constraintValidatorContext
     * @return 如果返回false，校验不通过，如果返回true，校验通过
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if(s==null){
            return false;
        }
        if(s.equals("Cat")||s.equals("Dog")){
            return true;
        }
        return false;
    }
}
